<template>
	<view class="newsbox">
		<view class="pic">
			<image :src="item.picurl" mode="aspectFill"></image>
		</view>
		<view class="text">
			<view class="title">{{ item.title }}</view>
			<view class="info" v-if="!item.looktime">
				<text>{{ item.author }}</text>
				<text>{{ item.hits }}</text>
			</view>
			<view class="info" v-else>
				<text>浏览时间:{{ item.looktime }}</text>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name:"newsbox",
		//组件属性值
		props:{
			item:{
				type:Object,
				default(){
					return {
						title:"组建内默认新闻标题",
						author:"张三",
						hits:0,
						picurl:"../../static/images/1.jpg"
					}
				}
			}
		},
		data() {
			return {
				
			};
		}
	}
</script>

<style lang="scss">
.newsbox{
	//flex布局
	display: flex;
	.pic{
		width: 230rpx;
		height: 160rpx;
		image{
			width: 100%;
			height: 100%;
		}
	}
	.text{
		flex: 1;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		padding-left: 20rpx;
		.title{
			font-size: 36rpx;
			color: #333333;
			
			//标题超过两行显示省略号
			text-overflow: -o-ellipsis-lastline;
			overflow: hidden;
			text-overflow: allipsis;
			display: -webkit-box;
			-webkit-line-clamp: 2;
			line-clamp: 2;
			-webkit-box-orient: vertical;
		}
		.info{
			font-size: 26rpx;
			color: #999999;
			text{
				padding-right: 30rpx;
			}
		}
	}
}
</style>